package DAO;

import java.sql.*;
import java.util.ArrayList;
import bean.loadListBean;
//import util.*;
import java.text.*;

import login.DBPool;

public class loadList {
	public loadList(){
		
	}

	static Connection conn;
	static PreparedStatement ps1;
	static ResultSet rs1;
	ArrayList arr;
	
	public static ArrayList getInfo(String currenUser){
		
		ArrayList result = new ArrayList();

		try{
			conn=DBPool.getConnection();
			System.out.println("getConnect() end!!");
			String sql ="select x,y,owner from b_record";
			ps1 = conn.prepareStatement(sql);
//			ps.setString(1, currenUser);
			System.out.println("ps execute!!");
			rs1 = ps1.executeQuery();
			System.out.println("re get!!");
			rs1.last();
			int allRecord = rs1.getRow();
			rs1.beforeFirst();
			int rowNum=1;
			
			while(rs1.next()){
				if(rowNum<=allRecord){
					loadListBean list = new loadListBean();
					list.setx(rs1.getDouble(1));
					list.sety(rs1.getDouble(2));
					list.setCurrentUser(rs1.getString(3));
					result.add(list);
				}
				rowNum++;
			}
			rs1.close();
			ps1.close();
			conn.close();
			System.out.print("Successful to get query data from db!!");
			

		} catch(Exception e){
			System.out.println(e.getMessage());
		}
		
		return result;
	}
}
